<%@page import="javax.portlet.PortletSession"%>
<%@ include file="/html/init.jsp" %>

<%-- 
<portlet:actionURL var="quickAddURL" name="quickAdd"/>
--%>

<liferay-portlet:actionURL var="quickAddURL" name="quickAdd" portletName="library_WAR_libraryportlet"/>

<aui:form action="<%= quickAddURL %>" portletNamespace="_library_WAR_libraryportlet_">
	<aui:input name="bookTitle"/>
	<aui:input name="author"/>
	<aui:button type="submit"/>
	<aui:button onClick="javascript:fireEvent();" value="Fire Event"/>
</aui:form>

<hr/>

<portlet:renderURL var="testURL">
	<portlet:param name="GREETING" value="Good Morning"/>
</portlet:renderURL>

<aui:a href="<%= testURL %>" label="test-url"/>

<h3><%= portletSession.getAttribute("SUCCESS_MSG", PortletSession.APPLICATION_SCOPE) %></h3>

<liferay-portlet:renderURL var="addBookURL" portletName="library_WAR_libraryportlet">
	<portlet:param name="jspPage" value="/html/form.jsp"/>
</liferay-portlet:renderURL>
<aui:a href="<%= addBookURL %>" label="add-new-book"/>

<liferay-portlet:renderURL var="listBooksURL" portletName="library_WAR_libraryportlet">
	<portlet:param name="jspPage" value="/html/list.jsp"/>
</liferay-portlet:renderURL>
<aui:a href="<%= listBooksURL %>" label="list-all-books"/>

<aui:script>
	function fireEvent() {
		
		alert('firing the event...');
		var payload = {
			bookTitle: 'abcd',
			author: 'xyz'
		};
		
		Liferay.fire('addBookEvent', payload);
	}
</aui:script>